
/*// 生物多样性分析，使用的json计算参数。
analysis_data = {
    // 参数1:
    database_type: "16S/18S/ITS",
    database_type_xxx: ["v3", "v4", "v5", "ITS1", "ITS2"],  // 待确认关键字

    // 参数2:
    data_format:"fasta/fastq",
    samples:[
        {sample_name:"M01", sample_path:"path/file1.fna"},
        {sample_name:"M02", sample_path:"path/file2.fna"},
        {sample_name:"M03", sample_path:"path/file3.fna"},
        {sample_name:"M04", sample_path:"path/file4.fna"},
    ],

    // 参数3:
    group:[
        {sample_name:"M01", group_name:"group1"},
        {sample_name:"M02", group_name:"group1"},
        {sample_name:"M03", group_name:"group2"},
        {sample_name:"M04", group_name:"group2"},
    ],

    // 参数4:
    cluster_otu_similarity: 0.97,
    cluster_otu_xxx: 2,  // 待确认关键字
    cluster_otu_xxx: 0.76, // 待确认关键字

    //参数5: （以下内容， 根据选择项，使用某一组）
    //16s_silva132(latest)
    database_seq:"/share/nas6/pub/database/cloud/silva/v132/rep_set/rep_set_all/97/silva132_97.fna",
    database_taxonomy:"/share/nas6/pub/database/cloud/silva/v132/taxonomy/taxonomy_all/97/taxonomy_7_levels_named.txt",

    //16S_silva128
    database_seq:"/share/nas6/pub/database/cloud/silva/v128/rep_set/rep_set_all/97/97_otus.fasta",
    database_taxonomy:"/share/nas6/pub/database/cloud/silva/v128/taxonomy/taxonomy_all/97/taxonomy_7_levels_named.txt",

    //18S_silva132(latest)
    database_seq:"/share/nas6/pub/database/silva/SILVA_132_QIIME_release/rep_set/rep_set_all/97/silva132_97.fna",
    database_taxonomy:"/share/nas6/pub/database/silva/SILVA_132_QIIME_release/taxonomy/taxonomy_all/97/taxonomy_7_levels_named.txt",

    //18S_silva128
    database_seq:"/share/nas6/pub/database/cloud/silva/v128/rep_set/rep_set_all/97/97_otus.fasta",
    database_taxonomy:"/share/nas6/pub/database/cloud/silva/v128/taxonomy/taxonomy_all/97/taxonomy_7_levels_named.txt",

    // ITS_unite7.2(latest)
    database_seq:"/share/nas6/pub/database/unite/v7.2/10_10_2017_global/sh_refs_qiime_ver7_97_s_10.10.2017.fasta",
    database_taxonomy:"/share/nas6/pub/database/unite/v7.2/10_10_2017_global/sh_taxonomy_qiime_ver7_97_s_10.10.2017.txt",
};*/

function SetUserParam(data, user_id)
{
    var token =  data.access_token.token;
    var refresh_token = data.refresh_token.token;
    console.log("token: "+token);
    console.log("r_token: " + refresh_token);

    window.localStorage.setItem("token", token);
    window.localStorage.setItem("refresh_token", refresh_token);
    window.localStorage.setItem("user_id", user_id);
}

function getToken() {
    return window.localStorage.getItem("token");
}

function ClearUserParam()
{
    window.localStorage.removeItem("user_id");
    window.localStorage.removeItem("token");
    window.localStorage.removeItem("refresh_token");
}


function  getUserID() {
    return window.localStorage.getItem("user_id");
}

function setRequestHeader(XMLHttpRequest) {
    XMLHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    XMLHttpRequest.setRequestHeader("Authorization", getToken());
}


//将form中的值转换为键值对。
function getFormJson(frm) {
    var o = {};
    var a = $(frm).serializeArray();
    $.each(a, function () {
        if (o[this.name] !== undefined) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });

    return o;
}

function MessageBox(state, title, message) {
    if(state == "show")
        $('#messagebox_id').css("display", "flex");
    else {
        $('#messagebox_id').css("display", "none");
        return;
    }

    if(title != "")
        $('#msgbox_title').html(title);

    $('#res_info').html(message);
}

function urlRoot() {
    return  "http://47.104.102.188:7979";
}

